﻿///<reference path="../lib/lt_tsbb.d.ts"/>
window.onload = () =>
{
    //注册块
    lighttool.tsbb.expr.expr_return.reg();
    lighttool.tsbb.expr.expr_addOne.reg();
    lighttool.tsbb.expr.expr_add.reg();

    var bplayer = new lighttool.tsbb.bbplayer("return", null);

    //连接流程块
    var a0 = bplayer.addBlock("add"); //4+5
    a0.inparams[0].constValue = 4;
    a0.inparams[1].constValue = 5;

    var a1 = bplayer.addBlock("addone");
    a1.linkInParamTo(0, a0, 0);
    //a1.inparams[1].constValue = 1;

    var a2 = bplayer.addBlock("add");
    a2.linkInParamTo(0, a0, 0);
    a2.linkInParamTo(1, a1, 0);

    var a3 = bplayer.addBlock("addone");
    a3.linkInParamTo(0, a2, 0);
    //return (4+5)+(4+5);,需要优化这个过程
    //连inparam 是推荐方式
    bplayer.getBeginBlock().linkInParamTo(0, a3, 0);
    ////但是连outparam比较直观
    //a1.linkOutParamTo(0, bplayer.getBeginBlock(), 0);

    //输出连接信息
    var json = bplayer.makeJson();
    alert("link info--------        \n" + JSON.stringify(json));
    //调用生成流程图方法
    // let a: BoockView = new BoockView();
    // a.creatFlow(bplayer);    

    var com = new lighttool.tsbb.ShaderCompiler();
    var code = com.compile(bplayer, [""]);
    alert("code:\n" + code);
};

